<template>
  <div class="sys-page">
    <el-button
      type="success"
      @click="refresh()"
      round
      style="float:right; margin-top:10px;"
      icon="el-icon-refresh"
    >刷新</el-button>
    <app-title :title="mainTitle"></app-title>
    <el-collapse>
      <el-collapse-item>
        <template slot="title">
          <span style="font-size:20px;color:orange;">搜索</span>
          <i class="header-icon el-icon-search"></i>
        </template>

        <app-search style=" display:flex; width:100%; ">
          <el-form :inline="true" :model="searchForm" :rules="addRules" ref="searchForm">
            <el-form-item label="身份证号查询" prop="sfzmhm">
              <el-input style=" width:300px;" v-model="searchForm.sfzmhm" placeholder="请输入18位身份证号"></el-input>
            </el-form-item>

            <el-form-item>
              <div class="block">
                <el-date-picker
                  v-model="value7"
                  type="daterange"
                  align="right"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="日期范围搜索起始"
                  end-placeholder="日期范围搜索结束"
                  :picker-options="pickerOptions2"
                ></el-date-picker>
              </div>
            </el-form-item>

            <el-form-item>
              <el-button icon="el-icon-delete" @click="reset">清空</el-button>
              <el-button id="zcc" type="primary" @click="timeValue" :disabled="disButton">查询</el-button>
            </el-form-item>
          </el-form>
        </app-search>
      </el-collapse-item>
    </el-collapse>

    <el-row>
      <el-col style="width: 100%" :span="20">
        <el-table :data="tableData" stripe style="width: 100%">
          <el-table-column type="index" width="50"></el-table-column>

          <el-table-column prop="username" label="处理人" width="180"></el-table-column>

          <el-table-column prop="userid" label="身份证号" width="250"></el-table-column>

          <el-table-column prop="lastaccesstime" label="最新操作操作时间" width="180"></el-table-column>

          <el-table-column label="处理车辆号牌" width="150">
            <template slot-scope="scope">
              <div style="margin-top:5px" v-for=" index in scope.row.plateidc" :key="index">
                <div @click="buttondialog2(index)">
                  <el-tag type="success">{{ index }}</el-tag>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="terminalid" label="使用终端id" width="90"></el-table-column>

          <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button type="text" @click="buttondialog(scope.row)">详细</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div align="center">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40,50]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount"
          ></el-pagination>
        </div>
      </el-col>
    </el-row>

    <el-dialog title="用户详情" :visible.sync="dialogTableVisible">
      <el-row>
        <el-col style="width: 100%" text-an :span="20">
          <el-table :data="dialogUserTableData" stripe style="width: 100%">
            <el-table-column prop="username" label="用户姓名" width="atuo"></el-table-column>

            <el-table-column prop="userid" label="用户身份证号" width="atuo"></el-table-column>

            <el-table-column prop="address" label="用户住址" width="atuo"></el-table-column>

            <el-table-column prop="telephone" label="用户联系电话" width="atuo"></el-table-column>
            <el-table-column prop="gender" label="用户性别" width="atuo"></el-table-column>
          </el-table>
        </el-col>
      </el-row>

      <el-row>
        <el-col style="width: 100%" :span="20">
          <el-table :data="dialogUserTableData" stripe style="width: 100%">
            <el-table-column prop="nation" label="国籍" width="atuo"></el-table-column>

            <el-table-column prop="authunit" label="发证机关" width="atuo"></el-table-column>

            <el-table-column prop="vtype" label="准驾车型" width="atuo"></el-table-column>

            <el-table-column prop="scorecost" label="累计记分" width="atuo"></el-table-column>

            <el-table-column prop="getlicensedate" label="初次领证日期" width="atuo"></el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-dialog>

    <el-dialog title="处理信息" :visible.sync="dialogTableVisible2">
      <el-button class="butxi" type="text" @click="butweiz">违章处理详细</el-button>
      <el-button class="butxii" type="text" @click="butweiz">详细</el-button>
      <el-row>
        <el-col style="width: 100%" :span="20">
          <el-table :data="dialogUserTableData2" stripe style="width: 100%">
            <el-table-column prop="plateid" label="处理车辆号牌" width="180"></el-table-column>

            <el-table-column prop="handlename" label="处理车辆中文品牌名称" width="280"></el-table-column>

            <el-table-column prop="handlemodel" label="车辆型号" width="180"></el-table-column>
          </el-table>
        </el-col>
      </el-row>

      <el-row>
        <el-col style="width: 100%" :span="20">
          <el-table :data="dialogUserTableData2" stripe style="width: 100%">
            <el-table-column prop="licenseItem" label="车辆出厂日期" width="180"></el-table-column>

            <el-table-column prop="handlelogo" label="车辆初次登记日期" width="280"></el-table-column>

            <el-table-column prop="people" label="车辆所有人" width="180"></el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-dialog>

    <el-dialog title="违章处理详细" :visible.sync="dialogTableVisible3">
      <el-row>
        <el-col style="width: 100%" :span="20">
          <el-table :data="dialogUserTableData3" stripe style="width: 100%">
            <el-table-column prop="wfitme" label="违法时间" width="120"></el-table-column>

            <el-table-column prop="location" label="违章地点" width="180"></el-table-column>

            <el-table-column prop="behavior" label="违章行为" width="180"></el-table-column>

            <el-table-column prop="minute" label="计分数" width="70"></el-table-column>

            <el-table-column prop="amount" label="罚款金额" width="80"></el-table-column>

            <el-table-column prop="delayed" label="滞纳金" width="70"></el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-dialog>

    <div style="width: 100%; display: flex;">
      <div id="main" style="width: 500px;height:300px;"></div>
      <div id="main2" style="width: 600px;height:400px;"></div>
    </div>
  </div>
</template>
<style scoped>
.butxi {
  color: #666;
  margin: 0% 0 0 80%;
  position: absolute;
  z-index: 1000;
}
.butxii {
  color: #666;
  margin: 13% 0 0 80%;
  position: absolute;
  z-index: 1000;
}
.el-table .warning-row {
  background: #f08080;
}
.block {
  float: right;
}
.el-dialog__wrapper >>> .el-dialog {
  width: 52%;
}
.el-table .success-row {
  background: #f0f9eb;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 480px;
}
</style>

<script>
export default {
  data() {
    var validateUserB = (rule, value, callback) => {
      var pattern = /^[0-9zZ]{1,}$/
      if (value === '') {
        this.disButton = true
        callback(new Error('搜索不能为空'))
      } else if (!pattern.test(value)) {
        this.disButton = true
        callback(new Error('搜索不为允许中文或特殊符号'))
      } else {
        this.disButton = false
      }
    }
    return {
      pickerOptions2: {
      },
      value7: '',

      picurl: window.axios_g.BASEURL,
      mainTitle: "终端实名用户信息查询",
      loading: false,
      picpath: '',
      totalCount: 0,
      pageNum: '',
      pageSize: 10,
      currentPage: 1,
      start: 1,
      tableDataTemp: [],
      tableData: [],
      tableData2: [],
      errorMsg: "您的信息有误，请联系管理员修改",
      reliable: true,
      dialogVisible: false,
      nameinfo: '',
      result: '处理结果',
      disButton: false,
      searchForm: {
        sfzmhm: ''
      },
      addRules: {
        sfzmhm: [
          { required: true, validator: validateUserB, trigger: 'change' }
        ]
      },
      //第一层对话框数据
      dialogUserTableData: [],
      dialogUserTableData2: [],
      dialogUserTableData3: [],

      dialogTableVisible: false,
      dialogTableVisible2: false,
      dialogTableVisible3: false,
      dialogFormVisible: false,
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },

    }
  },
  mounted() {
    this.query()
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (this.reliable === false) {
        return 'warning-row';
      } else {
        return 'success-row'
      }
    },
    //清空搜索框
    reset() {
      this.searchForm.sfzmhm = null
      this.value7 = null
    },
    //详细
    buttondialog(scope) {
      this.dialogTableVisible = true;
      let arr = []
      arr.push(scope)
      this.dialogUserTableData = arr
    },
    //车牌号处理详情查询
    butweiz() {
      this.HTTP.methods.apiGet("http://rap2api.taobao.org/app/mock/123866/terminal_userinfo/weizhang").then(res => {
        if (res.code != 200) {
          this.$message.error('返回数据命令码异常，请联系管理员');
        } else {
          console.log(res.data[0])
          let arr = []
          arr.push(res.data[0])
          this.dialogUserTableData3 = arr
          this.dialogTableVisible3 = true;
        }
      })
    },
    //车牌号查询
    buttondialog2(e) {
      let clcp = e
      this.HTTP.methods.apiPost("http://rap2api.taobao.org/app/mock/123866/terminal_userinfo/chepaihao", clcp).then(res => {
        if (res.code != 200) {
          this.$message.error('返回数据命令码异常，请联系管理员');
        } else {
          console.log(res.data[0])
          let arr = []
          arr.push(res.data[0])
          this.dialogUserTableData2 = arr
          this.dialogTableVisible2 = true;
        }
      })
    },
    // 初始化页面的查询
    query() {
      let page = {
        pageNum: this.pageNum,
        pageSize: this.pageSize
      }
      //   console.log(page)
      //   //http://106.12.97.38:8282/trff-web/trffweb/services/stat/tmUser.shtml
      //  // http://rap2api.taobao.org/app/mock/123866/jiazai
      //   this.HTTP.methods.apiPost("http://106.12.97.38:8282/trff-web/trffweb/services/stat/tmUser.shtml",page).then(res => {
      //     if (res.code != 200) {
      //       this.$message.error('返回数据命令码异常，请联系管理员');
      //     } else {
      //       console.log(res)
      //       this.tableData = res.data.rows
      //       this.totalCount = res.data.total
      //     }
      //   })
      let zxc = { "sfzmhm": "421003198810151013" }

      this.$axios({
        method: 'post',
        // headers:{
        //        'Content-Type': 'application/json'
        // },
        // data:{"sfzmhm":"421003198810151013"},
        data: {
          "sfzmhm": "421003198810151013"
        },
        url: 'http://106.12.97.38:8282/trff-web/trffweb/services/stat/tmUser.shtml',
      }).then(res => {
        if (res.code !== 20120) {
          console.log(res)
          this.tableData = res.data.rows
          this.totalCount = res.data.total
        }
      }).catch(err => {
        console.warn(`获取数据失败。${err}`)
      })



    },
    //每页显示数据量变更
    handleSizeChange: function (val) {
      this.HTTP.methods.apiGet("", val).then(res => {
        if (res.code != 200) {
          this.$message.error('返回数据命令码异常，请联系管理员');
        } else {
          this.tableData = res.data
          this.pageSize = val
        }
      })
    },
    //页码变更
    handleCurrentChange: function (val) {
      this.HTTP.methods.apiGet("", val).then(res => {
        if (res.code != 200) {
          this.$message.error('返回数据命令码异常，请联系管理员');
        } else {
          this.tableData = res.data
          this.pageNum = val
        }
      })
    },
    //刷新
    refresh() {
      this.query()
    },
    //搜索
    timeValue() {
      let msg = {
        sfzmhm: this.searchForm.sfzmhm,
        value7: this.value7.toString()
      }
      this.$axios({
        url: '/http://rap2api.taobao.org/app/mock/123866/trffweb/services/TmriOutAccess/MC01.shtml', msg
      }).then(res => {
        if (res.code == 200) {
          console.log(res)
        }
      }).catch(err => {
        console.warn(`获取数据失败。${err}`)
      })
    },

  }
}
</script>

<style scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>


    
